<?php

namespace IDock\Insurance\JTIC\Request;

use IDock\Insurance\JTIC\JTICEnums;
use IDock\Insurance\JTIC\Response\VehicleActualValueResponse;
use IDock\Visitor\VehicleActualValueVisitor;

class VehicleActualValueRequest extends AllJTICRequest
{

    protected $code = 'V204';

    protected $response = VehicleActualValueResponse::class;

    protected $urlTip = '计算车辆实际价值接口';

    /*** @var  VehicleActualValueVisitor $visitor */
    protected $visitor;

    public function generate(): array
    {
        $motorUsageTypeCode = '';
        $motorTypeCode = '';

        JTICEnums::getUsageTypeCode(
            $this->visitor->useNatureCode,
            $this->visitor->causeType,
            $this->visitor->carKindCode,
            $this->visitor->vehicleSeat,
            $this->visitor->vehicleTonnage,
            $motorUsageTypeCode,
            $motorTypeCode
        );

        return [
            'BasePart' => [
                'ProdGroup' => $this->visitor->isNewEnergy ? 'A335' : 'A339',
                'TCIEffectiveDate' => $this->visitor->startDate ? date('YmdHis',strtotime($this->visitor->startDate)) : '',
                'VCEffectiveDate' => $this->visitor->startDate ? date('YmdHis',strtotime($this->visitor->startDate)) : '',
                'FirstRegisterDate' => $this->visitor->firstRegisterDate,
                'VehicleId' => $this->visitor->vehicleModelCode,
                'OperateVehicleFlag' => '0',
                'MotorUsageTypeCode' => $motorUsageTypeCode,
                'MotorTypeCode' => $motorTypeCode,
                'TrafficVehicleType' => $this->visitor->vehicleStyleCode,
                'VehicleTonnage' => $this->visitor->vehicleTonnage,
            ],
        ];
    }
}
